* Runs regressions using the redrawn data created before *
* ---------------------------------------------------------------  *

*column numbers refer to the same columns in the baseline table
*calculates standard errors of the coefficients for Low and High skill wage
*coefficients etc are saved in local macros, then in save_run.do put into variables and appended to previous runs
*note that we also save the return code of each regresssion and run (in the storage_runs dataset this is also called rc_# where # is the column number)
	
* 1) LSW HSW GDPGAP | F+IY
di "run `run' - column 1"
qui ppmlhdfe F2.${depvar}_${ttt} LSW HSW GDPGAP stockown stockownzero stockother stockotherzero spilloversown spilloversownzero spilloversother spilloversotherzero if year>=1995 & missing_weights_1995==0 & maxweight_1995 < 1 & total_${depvar}_${ttt}_1995>0, absorb(lse_id yearindustry) vce(cluster lse_id)
local rc1=_rc
if _rc==0 {
    *store coefs
    mat b = e(b)
    *store covariance matrix
    mat v = e(V)
    *store first coefficient (LSW)
    local bLSW_1 = b[1,1]
    *store second coefficient (HSW)
    local bHSW_1 = b[1,2]
    *store standard error of first coefficient
    local stdLSW_1 = v[1,1]^(1/2)
    *store standard error of second coefficient
    local stdHSW_1 = v[2,2]^(1/2)
}

* 2) LSW HSW GDPGAP VAEMP | F+IY
di "run `run' - column 2"
qui ppmlhdfe F2.${depvar}_${ttt} LSW HSW GDPGAP VAEMP stockown stockownzero stockother stockotherzero spilloversown spilloversownzero spilloversother spilloversotherzero if year>=1995 & missing_weights_1995==0 & maxweight_1995 < 1 & total_${depvar}_${ttt}_1995>0, absorb(lse_id yearindustry) vce(cluster lse_id)
local rc2=_rc
if _rc==0 {
    mat b = e(b)
    mat v = e(V)
    local bLSW_2 = b[1,1]
    local bHSW_2 = b[1,2]
    local stdLSW_2 = v[1,1]^(1/2)
    local stdHSW_2 = v[2,2]^(1/2)
}

* 3) GDPGAP + GDPPC | F+IY
di "run `run' - column 3"
qui ppmlhdfe F2.${depvar}_${ttt} LSW HSW GDPGAP GDPPC stockown stockownzero stockother stockotherzero spilloversown spilloversownzero spilloversother spilloversotherzero if year>=1995 & missing_weights_1995==0 & maxweight_1995 < 1 & total_${depvar}_${ttt}_1995>0, absorb(lse_id yearindustry) vce(cluster lse_id)
local rc3=_rc
if _rc==0 {
    mat b = e(b)
    mat v = e(V)
    local bLSW_3 = b[1,1]
    local bHSW_3 = b[1,2]
    local stdLSW_3 = v[1,1]^(1/2)
    local stdHSW_3 = v[2,2]^(1/2)
}

* 4) GDPGAP | F+IY+CY
di "run `run' - column 4"
qui ppmlhdfe F2.${depvar}_${ttt} LSW HSW GDPGAP stockown stockownzero stockother stockotherzero spilloversown spilloversownzero spilloversother spilloversotherzero if year>=1995 & missing_weights_1995==0 & maxweight_1995 < 1 & total_${depvar}_${ttt}_1995>0, absorb(lse_id yearindustry yearctry) vce(cluster lse_id)

local rc4=_rc
if _rc==0 {
    mat b = e(b)
    mat v = e(V)
    local bLSW_4 = b[1,1]
    local bHSW_4 = b[1,2]
    local stdLSW_4 = v[1,1]^(1/2)
    local stdHSW_4 = v[2,2]^(1/2)
}	

* 5) GDPGAP + VAEMP | F+IY+CY
di "run `run' - column 5"
qui ppmlhdfe F2.${depvar}_${ttt} LSW HSW GDPGAP VAEMP stockown stockownzero stockother stockotherzero spilloversown spilloversownzero spilloversother spilloversotherzero if year>=1995 & missing_weights_1995==0 & maxweight_1995 < 1 & total_${depvar}_${ttt}_1995>0, absorb(lse_id yearindustry yearctry) vce(cluster lse_id)

local rc5=_rc
if _rc==0 {
    mat b = e(b)
    mat v = e(V)
    local bLSW_5 = b[1,1]
    local bHSW_5 = b[1,2]
    local stdLSW_5 = v[1,1]^(1/2)
    local stdHSW_5 = v[2,2]^(1/2)
}	

* 6) GDPGAP + GDPPC | F+IY+CY
di "run `run' - column 6"
qui ppmlhdfe F2.${depvar}_${ttt} LSW HSW GDPGAP GDPPC stockown stockownzero stockother stockotherzero spilloversown spilloversownzero spilloversother spilloversotherzero if year>=1995 & missing_weights_1995==0 & maxweight_1995 < 1 & total_${depvar}_${ttt}_1995>0, absorb(lse_id yearindustry yearctry) vce(cluster lse_id)

local rc6=_rc
if _rc==0 {
    mat b = e(b)
    mat v = e(V)
    local bLSW_6 = b[1,1]
    local bHSW_6 = b[1,2]
    local stdLSW_6 = v[1,1]^(1/2)
    local stdHSW_6 = v[2,2]^(1/2)
}


* 7) GDPGAP | F+IY+CY | foreign
di "run `run' - column 7"
qui ppmlhdfe F2.${depvar}_${ttt} LSW_foreign HSW_foreign GDPGAP_foreign stockown stockownzero stockother stockotherzero spilloversown spilloversownzero spilloversother spilloversotherzero if year>=1995 & missing_weights_1995==0 & missing_spill_weights_1995 == 0 & maxweight_1995 < 1 & total_${depvar}_${ttt}_1995>0,absorb(lse_id yearindustry yearctry) vce(cluster lse_id)

local rc7=_rc
if _rc==0 {
    mat b = e(b)
    mat v = e(V)
    local bLSW_7 = b[1,1]
    local bHSW_7 = b[1,2]
    local stdLSW_7 = v[1,1]^(1/2)
    local stdHSW_7 = v[2,2]^(1/2)
}

* 8) GDPGAP + VAEMP | F+IY+CY | foreign
di "run `run' - column 8"
qui ppmlhdfe F2.${depvar}_${ttt} LSW_foreign HSW_foreign GDPGAP_foreign VAEMP_foreign stockown stockownzero stockother stockotherzero spilloversown spilloversownzero spilloversother spilloversotherzero if year>=1995 & missing_weights_1995==0 & missing_spill_weights_1995 == 0 & maxweight_1995 < 1 & total_${depvar}_${ttt}_1995>0,absorb(lse_id yearindustry yearctry) vce(cluster lse_id)

local rc8=_rc
if _rc==0 {
    mat b = e(b)
    mat v = e(V)
    local bLSW_8 = b[1,1]
    local bHSW_8 = b[1,2]
    local stdLSW_8 = v[1,1]^(1/2)
    local stdHSW_8 = v[2,2]^(1/2)
}

* 9) GDPGAP + GDPPC | F+IY+CY | foreign
di "run `run' - column 9"
qui ppmlhdfe F2.${depvar}_${ttt} LSW_foreign HSW_foreign GDPGAP_foreign GDPPC_foreign stockown stockownzero stockother stockotherzero spilloversown spilloversownzero spilloversother spilloversotherzero if year>=1995 & missing_weights_1995==0 & missing_spill_weights_1995 == 0 & maxweight_1995 < 1 & total_${depvar}_${ttt}_1995>0,absorb(lse_id yearindustry yearctry) vce(cluster lse_id)
local rc9=_rc
if _rc==0 {
    mat b = e(b)
    mat v = e(V)
    local bLSW_9 = b[1,1]
    local bHSW_9 = b[1,2]
    local stdLSW_9 = v[1,1]^(1/2)
    local stdHSW_9 = v[2,2]^(1/2)
}